package com.gao.test;

import java.util.Arrays;

/**
 * @Author: ShanYuqing
 * @Version: v1.0
 */
public class BubbleSort {
    public static void main(String[] args) {
        int[] arr = {22, 55, 44, 33, 11};
        //外循环：比较的轮数
        for (int i = 0; i < arr.length - 1; i++) {
            //内循环：比较的次数
            //-i提高效率
            for (int j = 0; j < arr.length - 1 - i; j++) {
                if (arr[j] > arr[j + 1]) {
                    int temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                }
            }
        }
        System.out.println(Arrays.toString(arr));
    }

}
